package ljl.alg.wangzheng_camp.round1.sort;

import commons.ListNode;

public class _21_merge_two_sorted_list {
    
    /**
     * 普通解法没意思，试试递归
     *
     * 居然被我蒙对了，我真是走了狗屎运
     *
     * */
    public ListNode mergeTwoLists(ListNode list1, ListNode list2) {
        if (list1 == null) return list2;
        if (list2 == null) return list1;
        if (list1.val > list2.val) return mergeTwoLists(list2, list1);
        list1.next = mergeTwoLists(list1.next, list2);
        return list1;
    }
}
